﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Permission.aspx.cs" Inherits="SalesManagement.Modules.System.Permission" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script src="../../Javascript/Global.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
        function DocumentReady() {
           
            MethodNamespace.DocumentReady({
                success: function() {
                    storeMain.load();
                }
            });
        }
        function setView(el) {
            var data = el.record.data;
            var field = el.field;
            if (el.field == "IsView") {
                data.IsAdd = data.IsView;
                data.IsEdit = data.IsView;
                data.IsDelete = data.IsView;
                data.IsPrint = data.IsView;
                data.IsImport = data.IsView;
                data.IsExport = data.IsView;
                el.grid.store.commitChanges();
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="MethodNamespace">
        <Listeners>
            <DocumentReady Handler="DocumentReady();" />
        </Listeners>
    </ext:ResourceManager>
    <ext:Store ID="storeRole" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="RoleId">
                <Fields>
                    <ext:RecordField Name="RoleId" />
                    <ext:RecordField Name="RoleName" />
                    <ext:RecordField Name="Description" />
                    <ext:RecordField Name="IsActive" />
                    <ext:RecordField Name="CreatedDate" />
                    <ext:RecordField Name="CreatedBy" />
                    <ext:RecordField Name="UpdatedDate" />
                    <ext:RecordField Name="UpdatedBy" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="storeMain" runat="server" OnRefreshData="storeMain_OnRefreshDate"
        AutoLoad="false" GroupField="ModuleName">
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ScreenId">
                <Fields>
                    <ext:RecordField Name="ScreenId" />
                    <ext:RecordField Name="ScreenName" />
                    <ext:RecordField Name="RoleId" />
                    <ext:RecordField Name="ModuleName" />
                    <ext:RecordField Name="DisplayOrder" />
                    <ext:RecordField Name="IsAdd" />
                    <ext:RecordField Name="IsView" />
                    <ext:RecordField Name="IsDelete" />
                    <ext:RecordField Name="IsEdit" />
                    <ext:RecordField Name="IsPrint" />
                    <ext:RecordField Name="IsImport" />
                    <ext:RecordField Name="IsExport" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server" Layout="border">
        <Items>
            <ext:GridPanel ID="grdMain" runat="server" StripeRows="true" TrackMouseOver="true"
                AutoExpandColumn="ScreenName" Border="false" Region="Center" StoreID="storeMain">
                <TopBar>
                    <ext:Toolbar ID="tbMain" runat="server">
                        <Items>
                            <ext:Button ID="btnToggleGroups" runat="server" Text="Mở/Thu" Icon="TableSort">
                                <Listeners>
                                    <Click Handler="#{grdMain}.getView().toggleAllGroups();" />
                                </Listeners>
                            </ext:Button>
                            <ext:ToolbarSpacer />
                            <ext:ToolbarFill />
                            <ext:ComboBox ID="cboRole" FieldLabel="Nhóm người dùng" runat="server" Width="300"
                                ValueField="RoleId" DisplayField="RoleName" StoreID="storeRole">
                                <Listeners>
                                    <Select Handler="#{storeMain}.load();" />
                                </Listeners>
                            </ext:ComboBox>
                            <ext:ToolbarSpacer />
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ColumnID="ModuleName" DataIndex="ModuleName" Header="Chức năng" />
                        <ext:Column ColumnID="ScreenName" DataIndex="ScreenName" Header="Màn hình" />
                        <ext:CheckColumn Editable="true" ColumnID="IsView" DataIndex="IsView" Header="Xem"
                            Align="Center" Width="20">
                        </ext:CheckColumn>
                        <ext:CheckColumn Editable="true" ColumnID="IsAdd" DataIndex="IsAdd" Header="Thêm"
                            Align="Center" Width="20" />
                        <ext:CheckColumn Editable="true" ColumnID="IsEdit" DataIndex="IsEdit" Header="Cập nhật"
                            Align="Center" Width="20" />
                        <ext:CheckColumn Editable="true" ColumnID="IsDelete" DataIndex="IsDelete" Header="Xóa"
                            Align="Center" Width="20" />
                        <ext:CheckColumn Editable="true" ColumnID="IsPrint" DataIndex="IsPrint" Header="In ấn"
                            Align="Center" Width="20" />
                        <ext:CheckColumn Editable="true" ColumnID="IsImport" DataIndex="IsImport" Header="Nhập"
                            Align="Center" Width="20" />
                        <ext:CheckColumn Editable="true" ColumnID="IsExport" DataIndex="IsExport" Header="Xuất"
                            Align="Center" Width="20" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                </SelectionModel>
                <View>
                    <ext:GroupingView ID="GroupingView1" HideGroupedColumn="true" runat="server" ForceFit="true"
                        EnableRowBody="true" MarkDirty="false">
                    </ext:GroupingView>
                </View>
                <DirectEvents>
                    <AfterEdit OnEvent="grdMain_OnAfterEdit">
                        <ExtraParams>
                            <ext:Parameter Name="ScreenId" Value="e.record.data.ScreenId" Mode="Raw">
                            </ext:Parameter>
                            <ext:Parameter Name="RoleId" Value="e.record.data.RoleId" Mode="Raw">
                            </ext:Parameter>
                            <ext:Parameter Name="IsAdd" Value="e.record.data.IsAdd" Mode="Raw">
                            </ext:Parameter>
                            <ext:Parameter Name="IsView" Value="e.record.data.IsView" Mode="Raw">
                            </ext:Parameter>
                            <ext:Parameter Name="IsDelete" Value="e.record.data.IsDelete" Mode="Raw">
                            </ext:Parameter>
                            <ext:Parameter Name="IsEdit" Value="e.record.data.IsEdit" Mode="Raw">
                            </ext:Parameter>
                            <ext:Parameter Name="IsPrint" Value="e.record.data.IsPrint" Mode="Raw">
                            </ext:Parameter>
                            <ext:Parameter Name="IsImport" Value="e.record.data.IsImport" Mode="Raw">
                            </ext:Parameter>
                            <ext:Parameter Name="IsExport" Value="e.record.data.IsExport" Mode="Raw">
                            </ext:Parameter>
                        </ExtraParams>
                    </AfterEdit>
                </DirectEvents>
                <Listeners>
                    <AfterEdit Fn="setView" />
                    <Update Handler="alert('2');" />
                </Listeners>
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    </form>
</body>
</html>
